<header>
	<div class="a-bar">
		<a href="javascript:history.back()" class="a-back">
           	<i class="arr left"></i>
            返回
		</a>
		<div class="a-name">
			售后申请
		</div>
	</div>
</header>
<div class="full-screen">
	<form action="<{link app=b2c ctl=wap_member act=return_save}>"  method="post"  >
	<div class="m-after">
        <input type="hidden" name="order_id" value="<{$order_id}>">
		<div class="section s-after after-form">
			<p class="s-head">选择售后类型</p>
			<div class="s-box" style="width:4rem;">
				<input type="radio" id="s_reset" class="s-input" name="type"  value="1"  >
				<label class="s-form " for="s_reset">退货</label>
			</div>
			<div class="s-box" style="width:4rem;">
				<input type="radio" id="s_change" class="s-input" name="type" value="2" >
				<label class="s-form" for="s_change">换货</label>
			</div>
		</div>
		<div class="section s-after after-goods">
			<p class="s-head">选择申请数量</p>
			<ul class="after-list">

	        <{foreach from=$order.items item=item key=key name=name}>
	        	<input type="hidden" value="<{$item.quantity}>" class="max-g" >
	        	<input type="hidden" name="product_name[<{$item.products.product_id}>]" value="<{$item.name}>" >
	        	<input type="hidden" name="product_price[<{$item.products.product_id}>]" value="<{$item.price}>" >	
				<li class="after-item">
                    <div class="g-line">
						<div class="gline-checkbox">
							<input type="checkbox" id="Check[[<{$item.products.product_id}>]" name="product_bn[<{$item.products.product_id}>]" value='<{$item.bn}>' class="s-input ">
							<label class="c-label " for="Check[[<{$item.products.product_id}>]"></label>
						</div>
						<div class="gline-img">
							<a href="<{$item.link_url}>">
								<img src="<{$item.thumbnail_pic|default:$env.conf.site.default_thumbnail_pic|storager:'s'}>" alt="<{$item.name}>&nbsp;<{$item.attr}>">
							</a>
						</div>
						<div class="gline-info">
							<p class="gname"  style="line-height:inherit" ><{$item.name}></p>
							<div class="gnumber">
								<span class="gminus g-btn">-</span>
								<div class="gnum">
									<input type="text" name="product_nums[<{$item.products.product_id}>]"  class="ipt" value="1" id=""  onkeyup="this.value=this.value.replace(/[^\d]/g,'') " onafterpaste="this.value=this.value.replace(/[^\d]/g,'') " />
								</div>
								<span class="gmaxus g-btn">+</span>
								<p class="g-max">最大<{$item.quantity}>件</p>
							</div>
						</div>
					</div>
				</li>
                <{/foreach}>
			</ul>
		</div>
		<div class="section s-after">
			<p class="s-head">填写申请理由</p>
			<textarea name="title" id="" cols="30" rows="10" class="text-info"></textarea>
		</div>
		<div class="section s-after">
			<p class="s-head another">详细描述</p>
			<textarea name="content" id="" cols="30" rows="10"></textarea>
		</div>
		<div class="section s-after a-footer">
			<div class="gline-checkbox">
				<input type="checkbox" id="gCheck-a"  name="agree" class="s-input">
				<label class="c-label" for="gCheck-a"></label>
			</div>
			<p>我已阅读并同意遵守<a href="<{link app=b2c ctl=wap_member act=read}>">《售后服务协议》</a></p>
			<div class="btn">
				<button class="b-btn" type="submit" style="width:100%;display:block;height:inherit;" data-submit="1">提交申请</button>
			</div>
		</div>
	</div>
	</form>
</div>
<script type="text/javascript">
	$(".s-form").click(function(){
		$(this).addClass('f-current');
		var that = $(this).parents(".s-box").siblings('.s-box').children('.s-form');
		if(that.hasClass('f-current')&&that.siblings('.s-input').is(":checked")){
			that.removeClass('f-current');
			that.siblings('.s-input').prop("checked", false);
		}
	})
	$('.c-label').click(function(event){
		$(this).toggleClass('c-current');
	});
  $(".gmaxus").click(function(event) { 
  	var that = $(this).siblings('.gnum').children('.ipt')
  	var gmaxs = parseInt($(".max-g").val());  	
      num =that.val(); 
      num++; 
      if(num > gmaxs){
      	num = gmaxs;    	
      }  
      that.val(num);
  });
  $(".gminus").click(function(event) {
  	var that = $(this).siblings('.gnum').children('.ipt')
      num=that.val(); 
      if(num==1){
         that.val(1);
      }else{
      num--;
      that.val(num);     
      };
  });
/*  	var checkboxes = $(".checkboxes")
  	var clen = checkboxes.length;
  	function nth(){
 		var n = 0;
  		for(i=0;i<clen;i++){
  			if(checkboxes[i].checked){
  			n++;
  			}
  		}
  		alert(n)
  	}
  	$(".s-head").click(function(event) {
  		nth();
  	});*/
/*var ipt = $(".ipt").val();
if(ipt<0){
	alert("0")
}*/
  $(".btn").click(function(event) {
  	var ipt = $(".ipt").val();
  	var lastch = $("#gCheck-a").attr("checked");
  	var textval = $(".text-info").val();
  	var checkes = $("form").find('input[type="checkbox"]');
  	var len = $("form").find('input[type="checkbox"]').length;
  	var radios = $("#s_reset").attr("checked");
  	var radioc = $("#s_change").attr("checked");
	var clen =  $("input[type='checkbox']:checked").length;
  	for(var i=0 ;i<len-1; i++){
  		if(radioc == false && radios == false){
  		alert("请选择售后方式！")
  		return false;
  		}else if(clen < 0){
  		alert("请您选择申请数量！");
  		return false;
  		}else if(ipt<1){
  		alert("请您输入正确数量！");
  		return false;
  		}else if(textval == ""){
  		alert("请您输入申请理由！");
  		return false;
  		}else if(lastch == false){
  		alert("请您勾选《售后服务协议》！")
  		return false;
  		}else{
     			var interval;   	   
	 			$(function () {   
				interval = setTimeout(
					function(){
					window.close();
					}
				,"2000"); 
	 		});
  		}
  	}
  });
</script>
